package cn.seecoder.courselearning.controller;


import cn.seecoder.courselearning.service.course.AssignmenteService;
import cn.seecoder.courselearning.vo.ResultVO;
import cn.seecoder.courselearning.vo.course.AssignmentVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/assignments")
public class AssignmentsContraller {
    @Resource
    AssignmenteService service;

    @GetMapping("/{courseId}")
    public List<AssignmentVO> getAssignments(@PathVariable  Integer courseId){
            System.out.println(courseId+"获得题目");
            List<AssignmentVO> ans=service.getAssignments(courseId);
            return  ans;
    }
    @PostMapping("/add")
    public ResultVO<AssignmentVO> add(@RequestBody AssignmentVO assignment){
        return service.add(assignment);
    }
    @PostMapping("/edit")
    public ResultVO<AssignmentVO> edit(@RequestBody AssignmentVO assignment){
            return service.edit(assignment);
    }
    @GetMapping("/delete/{courseId}")
    public ResultVO<AssignmentVO> delete(@PathVariable  Integer courseId){
        return  service.delete(courseId);
    }
}

